<template>
	<view class="order-box">
		<view class="tab">
			<view class="item" @tap="tab(1)" :class="actInx ==1 ?'active':''">
				彩绘甲
			</view>
			<view class="item" @tap="tab(2)" :class="actInx ==2 ?'active':''">
				穿戴甲
			</view>
		</view>
		
		<view class="order-list">
			<view class="item" v-for="item in listData" :key="item.id" @tap="goDetail(item)">
				<view class="top">
					<image src="../../static/30.png" class="img"></image>
					<view class="r">
						{{item.goodsName}}
						<view class="price">
							<text  class="t">￥</text>{{item.goodsTotalPrice}}
						</view>
					</view>
					<!-- 1 未打印 2 打印完成 -->
					<view class="right-state" v-if="item.goodsOrderStatus == 1">
						未打印
					</view>
					<view class="right-state done" v-else>
						已完成
					</view>
				</view>
				<view class="desc">
					<text class="time">{{item.createTime}}</text>
					<view class="e-right">
						<button class="share" type="default" data-name="shareBtn" open-type="share" @tap="abc">
							<image src="../../static/share.png" class="icon" mode=""></image> 分享
						</button>
						<view class="scan" @tap="scanCode" v-if="item.goodsOrderStatus == 1">
							<image src="../../static/scan.png" class="icon" mode=""></image> 扫码打印
						</view>
						<view class="scan" @tap="goUrl('/pages/my/showYourSelf')" v-else>
							<image src="../../static/scan.png" class="icon" mode=""></image> 秀自己
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- <Footer :index="3"/> -->
		<!-- // 在 manifest.json 的 App SDK 配置里，勾选微信消息及朋友圈并填写相关微信 appkey -->
		<Tabbar :current="2"></Tabbar>
	</view>
</template>

<script>
	// import Footer from '@/components/footer.vue'
	import Tabbar from '@/components/tabBar.vue'
	import share from '@/utils/share.js'
	import {getSharePrintOrder,getMyOrderList,getQueryMyOrderList} from '@/api/order.js'
	export default {
		// mixins:[share],
		components:{
			// Footer,
			Tabbar
		},
		data() {
			return {
				actInx: 1,
				listData: []
			};
		},
		onLaunch() {
			//隐藏官方的tabBar
			uni.hideTabBar()
		},
		onLoad() {
			this.getList()
		},
		methods:{
			abc(){
				console.log(232)
			},
			tab(t){
				this.actInx = t
				if(t==2){
					uni.navigateTo({
						url:'/pages/my/orderList'
					})
				}
			},
			goUrl(url){
				uni.navigateTo({
					url
				})
			},
			goDetail(ops){
				uni.navigateTo({
					url:'/pages/order/orderDetail?id='+ops.id
				})
			},
			getList(){
				getQueryMyOrderList().then((res) =>{
					this.listData = res
					console.log(333,this.listData)
				})
			},
			getListJia(){
				getMyOrderList().then((res) =>{
					this.listData = res
					console.log(333,this.listData)
				})
			},
			scanCode() {
				// 允许从相机和相册扫码
				uni.scanCode({
					scanType: ["qrCode"],
					success: (res) => {
						console.log(res);
						if (res.result) {
							const val = res.result;
							console.log('scanCode',val)
						} else {
							console.log('请重新扫描');
							return false;
						}
					},
					fail: (res) => {
						console.log('未识别到二维码');
					}
				})
			},
			// 对扫码后，得到的url地址参数的处理。
			parseUrl(url) {
				let pattern = /(\w+)=([0-9a-zA-Z\u4e00-\u9fa5]+)/ig;
				let parames = {};
				url.replace(pattern, function(a, b, c) {
					parames[b] = c;
				});
				return parames;// 返回一个参数名：参数值 的对象。
			}
		}
	}
</script>

<style lang="less" scoped>
	@bg: #EB8DA7;
	.order-box{
		padding-top: 32rpx;
		margin: 0 26rpx;
		.tab{
			border-radius: 81rpx;
			background: #E4919D;
			height: 90rpx;
			color: #fff;
			display: flex;
			.item{
				flex: 1;
				font-size: 28rpx;
				font-weight: 500;
				border-radius: 81rpx;
				margin: 5rpx;
				line-height: 88rpx;
				text-align: center;
			}
			.active{
				color: #333;
				background: #fff;
			}
		}
		
		.order-list{
			margin-top: 32rpx;
			.item{
				// height: 280rpx;
				border-radius: 24rpx;
				background-color: #fff;
				padding: 32rpx;
				padding-right: 20rpx;
				margin-bottom: 32rpx;
			}
			.top{
				display: flex;
				position: relative;
				.img{
					width: 200rpx;
					height: 200rpx;
					border-radius: 16rpx;
					margin-right: 16rpx;
				}
				.r{
					font-size: 36rpx;
					color: #333;
					.price{
						color: #666;
						margin-top: 24rpx;
					}
					.t{
						font-size: 22rpx;
					}
				}
				.right-state{
					position: absolute;
					right: -22rpx;
					top: -32rpx;
					width: 92rpx;
					height: 44rpx;
					border-radius: 0px 24rpx 0px 24rpx;
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
					background: #F8D48A;
					font-family: PingFangSC-Medium;
					font-size: 20rpx;
					color: #fff;
				}
				.done{
					background: #AAAAAA;
				}
			}
			.desc{
				margin-top: 12rpx;
				display: flex;
				align-items: center;
				.time{
					font-size: 24rpx;
					color: #AAAAAA;
					flex: 1;
				}
				.icon{
					width: 32rpx;
					height: 32rpx;
					margin-right: 8rpx;
					position: relative;
					top: 8rpx;
				}
				.share{
					display: flex;
					flex-direction: row;
					justify-content: center;
					align-items: center;
					width: 144rpx;
					min-height: 1rpx;
					border-radius: 32rpx;
					box-sizing: border-box;
					border: 2rpx solid @bg;
					background-color: #fff !important;
					font-size: 28rpx;
					color: @bg;
					// margin-left: 26rpx;
					margin-right: 24rpx;
					display: inline-block;
					text-align: center;
					line-height: normal;
					padding: 10rpx 15rpx;
					padding-bottom: 13rpx;
				}
				.scan{
					display: flex;
					flex-direction: row;
					justify-content: center;
					align-items: center;
					width: 200rpx;
					// height: 64rpx;
					min-height: 1rpx;
					border-radius: 32rpx;
					box-sizing: border-box;
					background-color: @bg;
					border: 2rpx solid @bg;
					font-size: 28rpx;
					color: #fff;
					display: inline-block;
					text-align: center;
					line-height: normal;
					padding: 10rpx 15rpx;
					padding-bottom: 13rpx;
				}
				.e-right{
					text-align: right;
					display: flex;
					margin-left: 25rpx;
				}
			}
		}
	}
</style>
